package util.cardparse;

import business.entity.Card;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;



/**
 * 
 * 日期:2013-05-21
 * @author 陈贤森
 */
public final class ParseCardHelper {
	/**
	 * 把名片转化为json String对象
	 * @param card 要转化的Card
	 * @return json格式的String
	 */
	public static String encodeCard(Card card){
		Gson gson = new Gson();
		return gson.toJson(card, Card.class);
	}
	
	/**
	 * 把msg转化为Card对象
	 * @param msg 要转化的json String
	 * @return card对象
	 */
	public static Card decodeCard(String msg) throws JsonSyntaxException{
		Gson gson = new Gson();
		Card card = gson.fromJson(msg, Card.class);
		return card;
	}
}
